package com.dataease.indicatorqa.service.Impl;

import com.dataease.indicatorqa.service.IndicatorService;
import com.dataease.indicatorqa.util.DataEaseApiClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class IndicatorServiceImpl implements IndicatorService {

    @Autowired
    private DataEaseApiClient apiClient;

    @Override
    public Map<String, Object> queryIndicatorData(String indicatorId, String filters) {
        return apiClient.queryIndicatorData(indicatorId, filters);
    }

    @Override
    public List<Map<String, Object>> getIndicators(String tableCode) {
        return apiClient.getIndicators(tableCode);
    }

    @Override
    public List<Map<String, Object>> getTables() {
        return apiClient.getTables();
    }

    @Override
    public String recommendChartType(Map<String, Object> data, String question) {
        // 这里实现图表推荐逻辑
        // 简单示例：根据问题关键词推荐图表类型
        if (question.contains("趋势") || question.contains("变化")) {
            return "line";
        } else if (question.contains("占比") || question.contains("构成")) {
            return "pie";
        } else if (question.contains("排名") || question.contains("对比")) {
            return "bar";
        } else {
            return "table";
        }
    }
}